home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / SDKs / PCI Driver Development Kit / • Samples / Driver Samples / SCSI samples / SCSI 950629 / NCR_DriverProject / Src / NCRDriverPrivate.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-20  |  10.5 KB  |  317 lines  |  [TEXT/MPCC]

  1. /*                                    NCRDriverPrivate.h                                */
  2. /*
  3.  * NCRDriverPrivate.h
  4.  * Copyright © 1994-95 Apple Computer Inc. All rights reserved.
  5.  */
  6. /*    .___________________________________________________________________________________.
  7.       | This is a private interface file for the sample driver. It contains configuration    |
  8.     | parameters, driver-specific global definitions, and function prototypes.            |
  9.     | NCR chip specific information is in NCR53C825.h.                                    |
  10.     .___________________________________________________________________________________.
  11.  */
  12.  
  13. #ifndef __NCRSCSIDriverPrivate__
  14. #define __NCRSCSIDriverPrivate__
  15.  
  16. #define kVersionMajor        1
  17. #define kVersionMinor        0
  18. #define kVersionStage        final                    /* Res only                        */
  19. #define kVersionStageName    "fc"                    /* "d", "a", "b", "" for final    */
  20. #define kVersionStageValue    finalStage                /* Released                        */
  21. #define kVersionRevision    0
  22. /*
  23.  * Define the longest I/O transfer that the driver can perform. This determines the size
  24.  * of the physical mapping tables. (It's a define rather than an enum because it might 
  25.  * not fit into a C int).
  26.  */
  27. #if 0
  28. #define kNCRDriverMaxTransfer    (1024L * 1024L)        /* One Megabyte                    */
  29. #else /* Test partial preparation */
  30. #define kNCRDriverMaxTransfer    (8192L)                /* 4 Kb for partial prep test    */
  31. #endif
  32.  
  33. #define USE_LOG_LIBRARY            1                    /* Used for debugging            */
  34. #define LOG_TRACE                0                    /* Used for serious debugging    */
  35. #define RECORD_STATISTICS        1                    /* Used to analyse performance    */
  36. /*
  37.  * Use MEM space until AAPL,addresses is available. AAPL,addresses is indeed
  38.  * available, but I haven't tested I/O accesses.
  39.  */
  40. #define USE_MEM_ACCESS            1    /* Algorithm Testing    */
  41. /*
  42.  * USE_LOG_LIBRARY is set non-zero to compile in debugging functions. It should be set
  43.  * FALS during the final stages of software testing. If you compile under MPW, you would
  44.  * probably use a value defined in the MakeFile.
  45.  *
  46.  * LOG_TRACE logs entrances to all significant functions.
  47.  */
  48. #ifndef USE_LOG_LIBRARY
  49. #define USE_LOG_LIBRARY            0
  50. #endif
  51. #ifndef USE_MEM_ACCESS
  52. #define USE_MEM_ACCESS            1
  53. #endif
  54. #ifndef LOG_TRACE
  55. #define LOG_TRACE                USE_LOG_LIBRARY
  56. #endif
  57. #ifndef RECORD_STATISTICS
  58. #define RECORD_STATISTICS        0
  59. #endif
  60. #if USE_LOG_LIBRARY == 0
  61. #undef RECORD_STATISTICS
  62. #define RECORD_STATISTICS        0
  63. #endif
  64.  
  65. /*
  66.  * TEST_DRIVER is set TRUE by the test function. When non-zero it blocks definition
  67.  * of the driver's chip-access functions.
  68.  */
  69. #ifndef TEST_DRIVER
  70. #define TEST_DRIVER                0
  71. #endif
  72. #ifndef FALSE
  73. #define TRUE    1
  74. #define FALSE    0
  75. #endif
  76.  
  77. #define kCreatorType                'PSSD'            /* Registered Creator Type        */
  78. #define kDriverGlobalsPropertyName    "DriverGlobals"    /* -> GLOBAL area                */
  79. #define kDriverFailurePropertyName    "InitFailure"    /* Gets status on init failure    */
  80. #define ICON_Driver                    128                /* File Bundle icon                */
  81. #define BNDL_Resource                128
  82. /*
  83.  * The driver name is defined in the public header
  84.  */
  85.  
  86. #define kAuditIdent        (kCreatorType)            /* Audit Gestalt Selector            */
  87. #define kAuditEntries    256
  88.  
  89. #ifndef REZ
  90. /*
  91.  * For code segments only
  92.  */
  93. /*
  94.  * Note: Do not use pre-compiled headers as they have not been upgraded for
  95.  * the PCI driver definitions.
  96.  *
  97.  * Note that we have expanded all #include files to pre-load all dependencies.
  98.  * If you add #include files, be sure to all their precedent files are loaded
  99.  * from the {CIncludes} folder that contains the current PCI headers. This will
  100.  * be revised when the PCI-headers are merged into the common Universal Header
  101.  * distribution.
  102.  *
  103.  * This must be changed when the PCI-specific headers are merged into the
  104.  * standard distribution.
  105.  */
  106.  
  107. #include <ConditionalMacros.h>
  108. #if GENERATINGPOWERPC == 0
  109.     << error: the following will not work >>
  110. #endif
  111. #include <Types.h>
  112. #include <MixedMode.h>
  113. #include <OSUtils.h>
  114. #include <Files.h>
  115. #include <QuickdrawText.h>
  116. #include <QuickDraw.h>
  117. #include <Events.h>
  118. #include <Errors.h>
  119. #include <Memory.h>
  120. #include <Menus.h>
  121. #include <Controls.h>
  122. #include <Windows.h>
  123. #include <TextEdit.h>
  124. #include <Dialogs.h>
  125. #include <MachineExceptions.h>
  126. #include <PCI.h>
  127. #include <Kernel.h>
  128. #include <NameRegistry.h>
  129. #include <CodeFragments.h>
  130. #include <Devices.h>
  131. #include <Fonts.h>
  132. #include <Resources.h>
  133. #include <LowMem.h>
  134. #include <DriverServices.h>
  135. #include <Interrupts.h>
  136. #include <SCSI.h>
  137. #if defined(powerc) || defined (__powerc)        //** TEMP
  138.  
  139. #if USE_LOG_LIBRARY
  140. #include "LogLibrary.h"
  141. #endif
  142.  
  143. /*
  144.  * Include the public header files and the NCR-specific headers.
  145.  */
  146. #include "NCRDriver.h"
  147. #include "NCR53C825.h"
  148.  
  149. /*
  150.  * The UNUSED macro replaces #pragma unused (x)
  151.  */
  152. #define UNUSED(what) do { what = what; } while (0)
  153.  
  154. /*
  155.  * kIOBusyStatus is returned to the Device Manager if an asynchronous I/O
  156.  * request is pending.
  157.  */
  158. enum {
  159.     kIOBusyStatus            = 1
  160. };
  161.  
  162. /*
  163.  * These are private OSErr values that are passed to the Secondary Interrupt
  164.  * handler to start or continue I/O
  165.  */
  166. enum {
  167.     kIORequestStart            = +1000,    /* DoDriverIO -> Start NCR device            */
  168.     kPrepareMemoryStartTask,            /* Primary Interrupt -> PrepMemory Task        */
  169.     kPrepareMemoryRestart,                /* PrepMemory Task -> Restart NCR device    */
  170.     kBusResetRestart                    /* BusReset interim interrupt -> Delay        */
  171. };
  172.  
  173. /*
  174.  * Defined PBControl csCodes. Note that we don't support all of these.
  175.  */
  176. enum {
  177.     kControlGoodbye            = (-1),        /* Last call before close (ignored)            */
  178.     kControlKillIO            = 1,        /* This is handled by the Driver Manager    */
  179.     kControlVerifyDisk        = 5,        /* Verify disk                                */
  180.     kControlFormatDisk        = 6,        /* Format disk                                */
  181.     kControlEjectDisk        = 7,        /* Eject disk (ejectable media only)        */
  182.     kControlPhysicalIcon    = 21,        /* Return physical icon and where string    */
  183.     kControlMediaIcon        = 22,        /* Return media icon                        */
  184.     kControlDriveInfo        = 23,        /* Return drive info                        */
  185.     kControlPartitionSize    = 24        /* SCSI partition size                        */
  186. };
  187.  
  188. /*
  189.  * Defined PBStatus csCodes..
  190.  */
  191. enum {
  192.     kStatusDriveStatus        = 8            /* Drive status    -- currently unused            */
  193. };
  194. /*
  195.  * Defined Driver Gestalt selectors.
  196.  */
  197. #pragma options align=mac68k
  198. #endif
  199. /*
  200.  * This is a temporary inclusion until driver gestalts are added to the system headers.
  201.  */
  202. #include "TempDriverGestalt.h"
  203. #if defined(powerc) || defined(__powerc)        //** TEMP
  204. #pragma options align=reset
  205. #endif
  206. enum {
  207.     /*
  208.       * Power management
  209.      */
  210.     kDriverGestaltPowerSwitch    = 'ptog',    /* Support Power up/down switching?        */
  211.     kDriverGestaltPowerMode        = 'psta',    /* TRUE if in high-power mode            */
  212.     kDriverGestalt5MaxHighPower    = 'pmx5',    /* Max 5 volt uAmps in high-power mode    */
  213.     kDriverGestalt5MaxLowPower    = 'pmn5',    /* Max 5 volt uAmps in low-power mode    */
  214.     kDriverGestalt3MaxHighPower    = 'pmx3',    /* Max 3 volt uAmps in high-power mode    */
  215.     kDriverGestalt3MaxLowPower    = 'pmn3'    /* Max 3 volt uAmps in low-power mode    */
  216. };
  217.  
  218. /*
  219.  * SCSI command status (from status phase). Before returning final status, the
  220.  * driver checks that the command status is "good" (zero) -- otherwise, if no
  221.  * other errors are detected, it returns scsiNonZeroStatus.
  222.  */
  223. enum {
  224.     kScsiCommandStatusGood                = 0x00,    /* Normal completion        */
  225.     kScsiCommandStatusCheckCondition    = 0x02,    /* Need GetExtendedStatus    */
  226.     kScsiCommandStatusConditionMet        = 0x04,
  227.     kScsiCommandStatusBusy                = 0x08,    /* Device busy (self-test?)    */
  228.     kScsiCommandStatusIntermediate        = 0x10,    /* Intermediate status        */
  229.     kScsiStatusResConflict                = 0x18,    /* Reservation conflict        */
  230.     kScsiStatusQueueFull                = 0x28,    /* Target can't do command    */
  231.     kScsiStatusReservedMask                = 0x3e    /* Vendor specific?            */
  232. };
  233.  
  234. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  235.  * Our global storage is defined by this structure. This is not a requirement of the
  236.  * driver environment, but it collects globals into a coherent structure for debugging.
  237.  */
  238. #pragma options align=power
  239. struct DriverGlobal {
  240.     /*
  241.      * When we support concurrent I/O, we will need several of these.
  242.      * The perRequestRecord is defined in NCR53C825.h
  243.      */
  244.     PerRequestDataPtr        perRequestDataPtr;        /* Script communication area        */
  245.     /*
  246.      * DriverRefNum and RegEntryID are passed to us by the driver initialize command.
  247.      */
  248.     DriverRefNum            refNum;                /* Driver refNum for PB...            */
  249.     RegEntryID                deviceEntry;        /* Name Registry Entry ID            */
  250.     /*
  251.      * GetPCICardBaseAddress initialzes pciCardBaseAddress when the driver starts.
  252.      * this is a logical address that will be used to access the NCR card registers.
  253.      */
  254.     LogicalAddress            pciCardBaseAddress;            /* To access NCR registers    */
  255.     /*
  256.      * Interrupt Set globals.
  257.      */
  258.     InterruptSetMember        interruptSetMember;            /* Interrupt set identifier    */
  259.     void                    *interruptSetRefcon;        /* Existing refCon            */
  260.     InterruptHandler        interruptServiceFunction;    /* -> old isr function        */
  261.     InterruptEnabler        interruptEnableFunction;    /* -> interrupt enabler        */
  262.     InterruptDisabler        interruptDisableFunction;    /* -> interrupt disabler    */
  263.     /*
  264.      * We need to stall 12 PCI clock ticks between some NCR register reads.
  265.      */
  266.     AbsoluteTime            clockTick12;                /* for DelayForHardware        */
  267.     AbsoluteTime            msec250;                    /* for Bus Reset delay        */
  268.     /*
  269.      * Information retrieved from the System Registry
  270.      */
  271.     UInt8                    initiatorID;                /* SCSI Bus ID                */
  272.     Boolean                    initiatorIsInNVRAM;            /* Fetched from NVRAM?        */
  273.     /*
  274.       * Script patching variables. The script is prepared when the driver is
  275.      * initialized. Preparation determines the physical addresses of the scripts.
  276.      * GLOBAL.scriptIOTable is prepared when the driver is opened, and checkpointen
  277.      * when the driver is closed.
  278.      */
  279.     IOPreparationTable        scriptIOTable;                /* Prepare for the script    */
  280. #if USE_LOG_LIBRARY
  281.     OSType                    logIdentifier;                /* Who am I (the refNum)    */
  282.     LogRecordPtr            logRecordPtr;                /* Logging driver reference    */
  283. #endif
  284.     /*
  285.      * ncrSCSIScript is a copy (in physically-contiguous memory) of the script.
  286.      */
  287.     LogicalAddress            ncrSCSIScript;                /* Our SCSI script                */
  288.     ByteCount                ncrSCSIScriptSize;            /* Debug: script size in bytes    */
  289. };
  290. typedef struct DriverGlobal DriverGlobal, *DriverGlobalPtr;
  291. #pragma options align=reset
  292.  
  293. #if TEST_DRIVER == 0
  294. /*
  295.  * Globals and functions
  296.  */
  297. extern DriverGlobal        gDriverGlobal;                /* All interesting globals        */
  298. #define GLOBAL            (gDriverGlobal)                /* GLOBAL.field for references    */
  299. extern DriverDescription TheDriverDescription;        /* Exported to the universe        */
  300. extern UInt32            gNCRSCSIScript[];            /* Our SCSI script                */
  301. extern ByteCount        gNCRSCSIScriptSize;            /* Script size in bytes            */
  302.  
  303. /*
  304.  * PrepareMemoryForIO globals:
  305.  * pageSize                Size of the system's physical page (== 4096)
  306.  * pageMask                Mask to get the offset within this page.
  307.  */
  308. extern UInt32            gPageSize;                    /* GetLogicalPageSize()            */
  309. extern UInt32            gPageMask;                    /* gPageSize - 1                */
  310.  
  311. #include "NCRDriverPrototypes.h"
  312.  
  313. #endif /* If not TEST_DRIVER */
  314. #endif /* If not REZ */
  315. #endif /* __NCRSCSIDriverPrivate__ */
  316.  
  317.